home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14591 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: nntp-hub.barrnet.net!biosys!paralysys
  2. From: nasser@paralysys (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Which is better????
  5. Message-ID: <nhu3z4lge3.fsf@paralysys>
  6. Date: 1 Apr 96 04:25:40 GMT
  7. References: <3155559E.7120@dial.pipex.com>
  8.     <greg-2403961302300001@ts10-3.slip.uwo.ca>
  9. Sender: news@biosys.apldbio.COM
  10. Organization: Applied BioSystems
  11. In-reply-to: greg@ohs.uwo.ca's message of 24 Mar 96 18:02:30 GMT
  12. X-Newsreader: Gnus v5.1
  13.  
  14. In article <greg-2403961302300001@ts10-3.slip.uwo.ca> greg@ohs.uwo.ca (Greg Chapman) writes:
  15.  
  16.    In article <3155559E.7120@dial.pipex.com>, gs94@dial.pipex.com wrote:
  17.  
  18.    >I would prefer to use the faster method as I am iterating over some functions 
  19.    >several times passing megabytes of data (not all at once, in chunks of a few 
  20.    >dozen bytes at a time)
  21.  
  22.    Generally, pass a pointer if the data is longer then 4 bytes.
  23.  
  24.  
  25.  
  26. Always pass by reference when at all possible.
  27.  
  28. With C++, direct use of pointer use is very much 
  29. less needed than with C sinc one can use refernces
  30. now.
  31.  
  32. If the object being passed is not to be modified
  33. inside the called function, then use the const modifier, 
  34. this will make sure the compiler will check the 
  35. object is not being changed in the called function.
  36.  
  37. ALso remember than passing by value means the creation
  38. of temporary object (i..e constructors, destructors
  39. for the objects called etc..), but passing by refernce with
  40. const modifier will not cause this overhead.
  41.  
  42. Nasser
  43.  
  44.  
  45.  
  46.